// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Security;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Security.Json.FieldSecurityConverter))]
public sealed partial class FieldSecurity
{
#if NET7_0_OR_GREATER
	public FieldSecurity()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	public FieldSecurity()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	public Elastic.Clients.Elasticsearch.Fields? Except { get; set; }
	public Elastic.Clients.Elasticsearch.Fields? Grant { get; set; }
}

public readonly partial struct FieldSecurityDescriptor<TDocument>
{
	internal Elastic.Clients.Elasticsearch.Security.FieldSecurity Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public FieldSecurityDescriptor(Elastic.Clients.Elasticsearch.Security.FieldSecurity instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public FieldSecurityDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument>(Elastic.Clients.Elasticsearch.Security.FieldSecurity instance) => new Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument>(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument> descriptor) => descriptor.Instance;

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument> Except(Elastic.Clients.Elasticsearch.Fields? value)
	{
		Instance.Except = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument> Except(params System.Linq.Expressions.Expression<System.Func<TDocument, object?>>[] value)
	{
		Instance.Except = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument> Grant(Elastic.Clients.Elasticsearch.Fields? value)
	{
		Instance.Grant = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument> Grant(params System.Linq.Expressions.Expression<System.Func<TDocument, object?>>[] value)
	{
		Instance.Grant = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Security.FieldSecurity Build(System.Action<Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument>>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor<TDocument>(new Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}

public readonly partial struct FieldSecurityDescriptor
{
	internal Elastic.Clients.Elasticsearch.Security.FieldSecurity Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public FieldSecurityDescriptor(Elastic.Clients.Elasticsearch.Security.FieldSecurity instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public FieldSecurityDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor(Elastic.Clients.Elasticsearch.Security.FieldSecurity instance) => new Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor descriptor) => descriptor.Instance;

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor Except(Elastic.Clients.Elasticsearch.Fields? value)
	{
		Instance.Except = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor Except<T>(params System.Linq.Expressions.Expression<System.Func<T, object?>>[] value)
	{
		Instance.Except = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor Grant(Elastic.Clients.Elasticsearch.Fields? value)
	{
		Instance.Grant = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor Grant<T>(params System.Linq.Expressions.Expression<System.Func<T, object?>>[] value)
	{
		Instance.Grant = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Security.FieldSecurity Build(System.Action<Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Security.FieldSecurityDescriptor(new Elastic.Clients.Elasticsearch.Security.FieldSecurity(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}